import request from '@/config/axios'

// ERP 仓库库位 VO
export interface WarehouseZoneVO {
  id: number // 库位编号
  warehouseId: number // 仓库id
  name: string // 库位名称
  address: string // 库位地址
  sort: number // 排序
  remark: string // 备注
  principal: string // 负责人
  warehousePrice: number // 仓储费，单位：元
  truckagePrice: number // 搬运费，单位：元
  status: number // 开启状态
  defaultStatus: boolean // 是否默认
}

// ERP 仓库库位 API
export const WarehouseZoneApi = {
  // 查询ERP 仓库库位分页
  getWarehouseZonePage: async (params: any) => {
    return await request.get({ url: `/erp/warehouse-zone/page`, params })
  },

  // 查询ERP 仓库库位详情
  getWarehouseZone: async (id: number) => {
    return await request.get({ url: `/erp/warehouse-zone/get?id=` + id })
  },

  // 新增ERP 仓库库位
  createWarehouseZone: async (data: WarehouseZoneVO) => {
    return await request.post({ url: `/erp/warehouse-zone/create`, data })
  },

  // 修改ERP 仓库库位
  updateWarehouseZone: async (data: WarehouseZoneVO) => {
    return await request.put({ url: `/erp/warehouse-zone/update`, data })
  },

  // 删除ERP 仓库库位
  deleteWarehouseZone: async (id: number) => {
    return await request.delete({ url: `/erp/warehouse-zone/delete?id=` + id })
  },
  //导入excel
  importWarehouseZone: async (file) => {
    return await request.post({ url: `/erp/warehouse-zone/import`, data: { file } })
  },
  //获取excel模板
  getWarehouseZoneTemplate: async () => {
    return await request.download({ url: `/erp/warehouse-zone/get-import-template` })
  },

  // 导出ERP 仓库库位 Excel
  exportWarehouseZone: async (params) => {
    return await request.download({ url: `/erp/warehouse-zone/export-excel`, params })
  }
}